#include "SelectionGroup.h"

CMouseSelectionGroupItem::CMouseSelectionGroupItem(
    RWidgetWeakPtr InSelectTarget,
    std::shared_ptr<CMouseSelectionGroup> InGroup)
{
    SelectTarget=InSelectTarget;
    Group=InGroup;
}


void CMouseSelectionGroup::Select(RWidgetWeakPtr WidgetToSelect)
{
    Unselect();

    OnWidgetSelected.ExecuteIfBound(WidgetToSelect);

    SelectedWidget=WidgetToSelect;
    OnSelectionChanged.ExecuteIfBound();
}

void CMouseSelectionGroup::Unselect()
{
    if(SelectedWidget)
    {
        OnWidgetUnselected.ExecuteIfBound(SelectedWidget);
        SelectedWidget=nullptr;
        OnSelectionChanged.ExecuteIfBound();
    }
}

RWidgetWeakPtr CMouseSelectionGroup::GetSelectedWidget()
{
    return SelectedWidget;
}